package thesis;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;


import clustering.ClusterItem;

import com.aliasi.util.FeatureExtractor;


public class WordsFeatureExtractor<T> implements FeatureExtractor<ClusterItem> {
	private List<String> featureWords;
	
	public WordsFeatureExtractor(List<String> featureWords) {
		this.featureWords = featureWords;
	}
	
	public Map<String, ? extends Number> features(ClusterItem clusterItem) {
		Map<String, Integer> features = new Hashtable<String, Integer>();
		
		String preprocessedText = clusterItem.getPreprocessedText();
		
		for (String feature : featureWords){
			int featureValue = 0;
			if (preprocessedText.contains(" " + feature + " ")){
				featureValue = 1;
			}
			features.put(feature, featureValue);
		}
		
		return features;
	}
}
